package com.cjm.one.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.model.goods.entity.GoodsComment;
import com.cjm.one.model.goods.vo.GoodsCommentVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 29289
* @description 针对表【goods_comment】的数据库操作Mapper
* @createDate 2024-09-05 16:07:00
* @Entity com.one.goods.entity.GoodsComment
*/
public interface GoodsCommentMapper extends BaseMapper<GoodsComment> {

    GoodsCommentVo selectByCommentId(Long id);


    Page<GoodsComment> selectPageOrCommentTagList(Page<GoodsComment> page, Integer goodsId);

    Page<GoodsCommentVo> selectCommentPage(@Param("page") Page<GoodsCommentVo> page,
                                           @Param("goodsId") Long goodsId,
                                           @Param("sortOrder") String sortOrder,
                                           @Param("tagIds") List<Long> tagIds);

    @Select("SELECT AVG(score) FROM goods_comment WHERE goods_id = #{id}")
    Double getAverageScore(@Param("id") Long id);

    void insertBatch(List<GoodsComment> goodsComments);
}




